summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua7
-rw-r--r--MCServer/Plugins/InfoDump.lua21
-rw-r--r--src/Bindings/PluginManager.cpp7
-rw-r--r--src/ClientHandle.cpp2
4 files changed, 27 insertions, 10 deletions
diff --git a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua
index 79b7bb055..db7eb97d1 100644
--- a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua
+++ b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua
@@ -16,10 +16,9 @@ return
If the command is in-game, the first parameter to the hook function is the {{cPlayer|player}} who's
executing the command. If the command comes from the server console, the first parameter is nil.</p>
<p>
- The server calls this hook even for unregistered (unknown) console commands. However, it doesn't call
- the hook for unregistered in-game commands, simply because there's no way to distinguish between a
- command and a chat message. If a plugin needs to intercept unknown in-game commands, it should use the
- {{OnChat|HOOK_CHAT}} hook.
+ The server calls this hook even for unregistered (unknown) console commands. It also calls the hook
+ for unknown in-game commands, as long as they begin with a slash ('/'). If a plugin needs to intercept
+ in-game chat messages not beginning with a slash, it should use the {{OnChat|HOOK_CHAT}} hook.
]],
Params =
{
diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua
index ab4dfd861..a715c9a18 100644
--- a/MCServer/Plugins/InfoDump.lua
+++ b/MCServer/Plugins/InfoDump.lua
@@ -65,8 +65,12 @@ local function ForumizeString(a_Str)
a_Str = a_Str:gsub("{%%p}", "\n\n")
a_Str = a_Str:gsub("{%%b}", "[b]"):gsub("{%%/b}", "[/b]")
a_Str = a_Str:gsub("{%%i}", "[i]"):gsub("{%%/i}", "[/i]")
- a_Str = a_Str:gsub("{%%list}", "[list]"):gsub("{%%/list}", "[/list]")
- a_Str = a_Str:gsub("{%%li}", "[*]"):gsub("{%%/li}", "")
+ a_Str = a_Str:gsub("{%%list}", "\n[list]"):gsub("{%%/list}", "[/list]")
+ a_Str = a_Str:gsub("{%%li}", "\n[*]"):gsub("{%%/li}", "\n")
+
+ -- Process links: {%a LinkDestination}LinkText{%/a}
+ a_Str = a_Str:gsub("{%%a%s([^}]*)}([^{]*){%%/a}", "[url=%1]%2[/url]")
+
-- TODO: Other formatting
return a_Str
@@ -106,8 +110,12 @@ local function GithubizeString(a_Str)
a_Str = a_Str:gsub("{%%p}", "\n\n")
a_Str = a_Str:gsub("{%%b}", "**"):gsub("{%%/b}", "**")
a_Str = a_Str:gsub("{%%i}", "*"):gsub("{%%/i}", "*")
- a_Str = a_Str:gsub("{%%list}", ""):gsub("{%%/list}", "")
- a_Str = a_Str:gsub("{%%li}", " - "):gsub("{%%/li}", "")
+ a_Str = a_Str:gsub("{%%list}", "\n"):gsub("{%%/list}", "\n")
+ a_Str = a_Str:gsub("{%%li}", "\n - "):gsub("{%%/li}", "")
+
+ -- Process links: {%a LinkDestination}LinkText{%/a}
+ a_Str = a_Str:gsub("{%%a%s([^}]*)}([^{]*){%%/a}", "[%2](%1)")
+
-- TODO: Other formatting
return a_Str
@@ -592,7 +600,10 @@ local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo)
DumpCommandsForum(a_PluginInfo, f)
DumpPermissionsForum(a_PluginInfo, f)
if (a_PluginInfo.SourceLocation ~= nil) then
- f:write("[b][color=blue]Source:[/color] [url=", a_PluginInfo.SourceLocation, "]Link[/url][/b]")
+ f:write("\n[b]Source[/b]: ", a_PluginInfo.SourceLocation, "\n")
+ end
+ if (a_PluginInfo.DownloadLocation ~= nil) then
+ f:write("[b]Download[/b]: ", a_PluginInfo.DownloadLocation)
end
f:close()
return true
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 15bea22bd..db2493955 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -1445,6 +1445,13 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player,
if (cmd == m_Commands.end())
{
// Command not found
+ // If it started with a slash, ask the plugins if they still want to handle it:
+ if (!a_Command.empty() && (a_Command[0] == '/'))
+ {
+ CommandResult Result = crUnknownCommand;
+ CallHookExecuteCommand(&a_Player, Split, a_Command, Result);
+ return Result;
+ }
return crUnknownCommand;
}
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 7117229f7..c8ccc1cf5 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1473,7 +1473,7 @@ void cClientHandle::HandleChat(const AString & a_Message)
Color.clear();
}
Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color);
- Msg.ParseText(a_Message);
+ Msg.ParseText(Message);
Msg.UnderlineUrls();
m_Player->GetWorld()->BroadcastChat(Msg);
}